package com.hub.esdemo.config;


import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ author 飞天蝙蝠
 * @ date & time 2024/12/28 12:41
 */
@Configuration
public class RabbitMQConfig {

    public static final String EXCHANGE_NAME = "exchange_demo";
    public static final String QUEUE_NAME = "queue_demo";
    public static final String ROUTING_KEY = "routing_key_demo";

    @Bean
    public Queue queue() {
        return new Queue(QUEUE_NAME, true);
    }

    @Bean
    public TopicExchange exchange() {
        return new TopicExchange(EXCHANGE_NAME);
    }

    @Bean
    public Binding binding(Queue queue, TopicExchange exchange) {
        return BindingBuilder.bind(queue).to(exchange).with(ROUTING_KEY);
    }
}
